﻿// ....................................................................................................................
//	Author: Copyright (C) 2012 Ing. Marek Hubal
//	Email: hubal@acasoftware.org
// ....................................................................................................................

using System;

namespace core
{
    /// <summary>Trieda IFileExplorerForm_ExportListToFile</summary>
    public class IFileExplorerForm_ExportListToFile : IForm
    {
        /// <summary>Trieda IExportListToFileStr</summary>
        public class IExportListToFileStr
        {
            public const int OUTPUT_MODE_TXT = 0;
            public const int OUTPUT_MODE_HTML = 1;
            public const int OUTPUT_MODE_XML = 2;

            public int OutputMode; // Mod vystupu
            public int ExportDepth; // Hlbka exportu
            public bool ExportDirNames; // Priznak exportovania nazvov priecinkov
            public bool ExportFullName; // Priznak exportu plneho nazvu
            public bool ExportSize; // Priznak exportu dlzky
            public bool ExportDCreate; // Priznak exportu datumu vytvorenia
            public bool ExportDModify; // Priznak exportu datumu zmeny
            public bool ExportDLastAccess; // Priznak exportu datumu posledneho pristupu
            public bool ExportAttributes; // Priznak exportu atributov

            protected System.IO.StreamWriter FOutputStream; // Vystupny stream
            protected bool FWaitForDirectory;
            protected int FFilesCount;

            /// <summary>Property: FilterString</summary>
            public string FilterString
            {
                get
                {
                    switch (OutputMode)
                    {
                        case OUTPUT_MODE_HTML: return lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_5_2;
                        case OUTPUT_MODE_XML: return lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_5_3;
                        default: return lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_5_1;
                    }
                }
            }

            /// <summary>Konstruktor</summary>
            public IExportListToFileStr()
            {
                OutputMode = OUTPUT_MODE_TXT;
                ExportDepth = -1;
                ExportDirNames = true;
                ExportFullName = false;
                ExportSize = false;
                ExportDCreate = false;
                ExportDModify = false;
                ExportDLastAccess = false;
                ExportAttributes = false;
            }

            /// <summary>Skopirovanie obsahu objektu</summary>
            /// <param name="pValue"></param>
            public void Assign(IExportListToFileStr pValue)
            {
                OutputMode = pValue.OutputMode;
                ExportDepth = pValue.ExportDepth;
                ExportDirNames = pValue.ExportDirNames;
                ExportFullName = pValue.ExportFullName;
                ExportSize = pValue.ExportSize;
                ExportDCreate = pValue.ExportDCreate;
                ExportDModify = pValue.ExportDModify;
                ExportDLastAccess = pValue.ExportDLastAccess;
                ExportAttributes = pValue.ExportAttributes;
            }
            /// <summary>Serializacia obsahu</summary>
            /// <returns>serializovany obsah</returns>
            public string Serialize()
            {
                using (IParamList L = new IParamList())
                {
                    L.SetParam("OM", OutputMode);
                    L.SetParam("ED", ExportDepth);
                    L.SetParam("EDN", ExportDirNames);
                    L.SetParam("EFN", ExportFullName);
                    L.SetParam("ES", ExportSize);
                    L.SetParam("EDC", ExportDCreate);
                    L.SetParam("EDM", ExportDModify);
                    L.SetParam("EDLA", ExportDLastAccess);
                    L.SetParam("EA", ExportAttributes);
                    return L.Serialize(true);
                }
            }
            /// <summary>Deserializacia obsahu</summary>
            /// <param name="pData">data</param>
            public void Deserialize(string pData)
            {
                using (IParamList L = new IParamList())
                {
                    L.Deserialize(pData, true);
                    OutputMode = L.GetParam("OM", OutputMode);
                    ExportDepth = L.GetParam("ED", ExportDepth);
                    ExportDirNames = L.GetParam("EDN", ExportDirNames);
                    ExportFullName = L.GetParam("EFN", ExportFullName);
                    ExportSize = L.GetParam("ES", ExportSize);
                    ExportDCreate = L.GetParam("EDC", ExportDCreate);
                    ExportDModify = L.GetParam("EDM", ExportDModify);
                    ExportDLastAccess = L.GetParam("EDLA", ExportDLastAccess);
                    ExportAttributes = L.GetParam("EA", ExportAttributes);
                }
            }

            /// <summary>Zmena dat pomocou formulara</summary>
            /// <returns>true / false</returns>
            public bool EditWithForm()
            {
                using (IFileExplorerForm_ExportListToFile F = new IFileExplorerForm_ExportListToFile()) // Vytvorim form
                {
                    F.Value.Assign(this);
                    bool B = F.ShowDialog() == System.Windows.Forms.DialogResult.OK;
                    if (B) Assign(F.Value);
                    return B;
                }
            }

            /// <summary>Nastavenie vystupneho streamu</summary>
            /// <param name="pStream">objekt streamu</param>
            public void SetOutputStream(System.IO.Stream pStream)
            {
                FWaitForDirectory = true;
                FFilesCount = 0;

                try
                {
                    switch (OutputMode)
                    {
                        case OUTPUT_MODE_XML:
                            {
                                FOutputStream = new System.IO.StreamWriter(pStream, System.Text.Encoding.UTF8);
                                FOutputStream.WriteLine(string.Format("<?xml version=\"1.0\" encoding=\"utf-8\" ?><content>"));
                            } break;
                        case OUTPUT_MODE_HTML:
                            {
                                FOutputStream = new System.IO.StreamWriter(pStream, System.Text.Encoding.Default);
                                FOutputStream.WriteLine(string.Format("<!DOCTYPE html><html><head><title>{0}</title></head><body>", lang.FILE_EXPLORER_TEXT_40_8));
                            } break;
                        default:
                            {
                                FOutputStream = new System.IO.StreamWriter(pStream, System.Text.Encoding.Default);
                            } break;
                    }
                }
                catch
                {
                }
            }
            /// <summary>Uzatovrenie vystupneho streamu</summary>
            public void CloseOutputStream()
            {
                try
                {
                    switch (OutputMode)
                    {
                        case OUTPUT_MODE_HTML:
                            {
                                if (FFilesCount != 0) FOutputStream.WriteLine("</table>");
                                FOutputStream.WriteLine("</body></html>");
                            } break;
                        case OUTPUT_MODE_XML:
                            {
                                FOutputStream.WriteLine("</content>");
                            } break;
                    }
                }
                catch
                {
                }
                FOutputStream.Close(); FOutputStream.Dispose();
            }
            /// <summary>Zaradenie suboru</summary>
            /// <param name="pName">nazov</param>
            /// <param name="pFullName">nazov aj s cestou</param>
            /// <param name="pSize">dlzka</param>
            /// <param name="pDCreate">cas vytvorenia</param>
            /// <param name="pDModify">cas zmeny</param>
            /// <param name="pDLastAccess">cas posledneho pristupu</param>
            /// <param name="pAttributes">atributy</param>
            public void AddFile(string pName, string pFullName, long pSize, DateTime pDCreate, DateTime pDModify, DateTime pDLastAccess, uint pAttributes)
            {
                switch (OutputMode)
                {
                    case OUTPUT_MODE_HTML: AddFile_HtmlMode(pName, pFullName, pSize, pDCreate, pDModify, pDLastAccess, pAttributes); break;
                    case OUTPUT_MODE_XML: AddFile_XmlMode(pName, pFullName, pSize, pDCreate, pDModify, pDLastAccess, pAttributes); break;
                    default: AddFile_TxtMode(pName, pFullName, pSize, pDCreate, pDModify, pDLastAccess, pAttributes); break;
                }
                FFilesCount++;
            }
            /// <summary>Zaradenie priecinku</summary>
            /// <param name="pName">nazov</param>
            /// <param name="pFullName">nazov aj s cestou</param>
            /// <param name="pEmpty">priznak prazdneho priecinku</param>
            public void AddDirectory(string pName, string pFullName, bool pEmpty)
            {
                switch (OutputMode)
                {
                    case OUTPUT_MODE_HTML: AddDirectory_HtmlMode(pName, pFullName); break;
                    case OUTPUT_MODE_XML: AddDirectory_XmlMode(pName, pFullName); break;
                    default: AddDirectory_TxtMode(pName, pFullName); break;
                }
                FWaitForDirectory = false; 
            }

            /// <summary>Zaradenie priecinku - mod txt</summary>
            /// <param name="pName">nazov</param>
            /// <param name="pFullName">plny nazov</param>
            /// <param name="pEmpty">priznak prazdneho priecinku</param>
            public void AddDirectory_TxtMode(string pName, string pFullName, bool pEmpty = false)
            {
                if (!ExportDirNames) return; // Nezapisovat nazvy priecinkov?
                try
                {
                    if (ExportFullName) FOutputStream.WriteLine(string.Format(pEmpty ? lang.FILE_EXPLORER_TEXT_40_4 : lang.FILE_EXPLORER_TEXT_40_4, pFullName));
                    else FOutputStream.WriteLine(string.Format(pEmpty ? lang.FILE_EXPLORER_TEXT_40_4 : lang.FILE_EXPLORER_TEXT_40_4, pName));
                }
                catch
                {
                }
                FFilesCount = 0;
            }
            /// <summary>Zaradenie priecinku - mod txt</summary>
            /// <param name="pName">nazov</param>
            /// <param name="pFullName">plny nazov</param>
            /// <param name="pEmpty">priznak prazdneho priecinku</param>
            public void AddDirectory_HtmlMode(string pName, string pFullName, bool pEmpty = false)
            {
                if (!ExportDirNames) return; // Nezapisovat nazvy priecinkov?
                try
                {
                    if (FFilesCount != 0) FOutputStream.WriteLine("</table>");
                    if (ExportFullName) FOutputStream.WriteLine(string.Format(pEmpty ? lang.FILE_EXPLORER_TEXT_40_6 : lang.FILE_EXPLORER_TEXT_40_6, pFullName));
                    else FOutputStream.WriteLine(string.Format(pEmpty ? lang.FILE_EXPLORER_TEXT_40_6 : lang.FILE_EXPLORER_TEXT_40_6, pName));
                }
                catch
                {
                }
                FFilesCount = 0;
            }
            /// <summary>Zaradenie priecinku - mod txt</summary>
            /// <param name="pName">nazov</param>
            /// <param name="pFullName">plny nazov</param>
            /// <param name="pEmpty">priznak prazdneho priecinku</param>
            public void AddDirectory_XmlMode(string pName, string pFullName, bool pEmpty = false)
            {
                if (!ExportDirNames) return; // Nezapisovat nazvy priecinkov?
                try
                {
                    FOutputStream.WriteLine("<directory>");
                    if (ExportFullName) 
                    {
                        FOutputStream.WriteLine("<name />");
                        FOutputStream.WriteLine(string.Format("<fullname>{0}</fullname>", pFullName));
                    }
                    else 
                    {
                        FOutputStream.WriteLine(string.Format("<name>{0}</name>", pName));
                        FOutputStream.WriteLine("<fullname />");
                    }
                    FOutputStream.WriteLine("</directory>");
                }
                catch
                {
                }
                FFilesCount = 0;
            }
            /// <summary>Zaradenie suboru</summary>
            /// <param name="pName">nazov</param>
            /// <param name="pFullName">nazov aj s cestou</param>
            /// <param name="pSize">dlzka</param>
            /// <param name="pDCreate">cas vytvorenia</param>
            /// <param name="pDModify">cas zmeny</param>
            /// <param name="pDLastAccess">cas posledneho pristupu</param>
            /// <param name="pAttributes">atributy</param>
            public void AddFile_TxtMode(string pName, string pFullName, long pSize, DateTime pDCreate, DateTime pDModify, DateTime pDLastAccess, uint pAttributes)
            {
                string SizeStr = ExportSize ? ICore.AlignStringFromLeft(ICore.ToStr(pSize), ' ', 16) + " | " : "";
                string DCreateStr = ExportDCreate ? ICore.AlignStringFromLeft(ICore.DateTime2Str(pDCreate), ' ', 19) + " | " : "";
                string DModifyStr = ExportDCreate ? ICore.AlignStringFromLeft(ICore.DateTime2Str(pDModify), ' ', 19) + " | " : "";
                string DLastAccessStr = ExportDCreate ? ICore.AlignStringFromLeft(ICore.DateTime2Str(pDLastAccess), ' ', 19) + " | " : "";
                string AttrStr = ExportAttributes ? ICore.AlignStringFromLeft(INode.FormatAttributesAsString(pAttributes, (char)0), ' ', 6) + " | " : "";
                try
                {
                    if ((ExportDirNames && (!FWaitForDirectory))) FOutputStream.Write("\t");
                    if (ExportFullName) FOutputStream.WriteLine(string.Format(lang.FILE_EXPLORER_TEXT_40_5, SizeStr, DCreateStr, DModifyStr, DLastAccessStr, AttrStr, pFullName));
                    else FOutputStream.WriteLine(string.Format(lang.FILE_EXPLORER_TEXT_40_5, SizeStr, DCreateStr, DModifyStr, DLastAccessStr, AttrStr, pName));
                }
                catch
                {
                }
            }
            /// <summary>Zaradenie suboru</summary>
            /// <param name="pName">nazov</param>
            /// <param name="pFullName">nazov aj s cestou</param>
            /// <param name="pSize">dlzka</param>
            /// <param name="pDCreate">cas vytvorenia</param>
            /// <param name="pDModify">cas zmeny</param>
            /// <param name="pDLastAccess">cas posledneho pristupu</param>
            /// <param name="pAttributes">atributy</param>
            public void AddFile_HtmlMode(string pName, string pFullName, long pSize, DateTime pDCreate, DateTime pDModify, DateTime pDLastAccess, uint pAttributes)
            {
                string SizeStr = ExportSize ? ICore.ToStr(pSize) : "";
                string DCreateStr = ExportDCreate ? ICore.DateTime2Str(pDCreate) : "";
                string DModifyStr = ExportDCreate ? ICore.DateTime2Str(pDModify) : "";
                string DLastAccessStr = ExportDCreate ? ICore.DateTime2Str(pDLastAccess) : "";
                string AttrStr = ExportAttributes ? INode.FormatAttributesAsString(pAttributes, (char)0) : "";

                if (SizeStr != "") SizeStr = "<td align=right>" + SizeStr + "</td>";
                if (DCreateStr != "") DCreateStr = "<td align=center>" + DCreateStr + "</td>";
                if (DModifyStr != "") DModifyStr = "<td align=center>" + DModifyStr + "</td>";
                if (DLastAccessStr != "") DLastAccessStr = "<td align=center>" + DLastAccessStr + "</td>";
                if (AttrStr != "") AttrStr = "<td align=center>" + AttrStr + "</td>";

                try
                {
                    if (FFilesCount == 0) FOutputStream.WriteLine("<table align=center width=100% cellspacing=0 cellpadding=2>");
                    if (ExportFullName) FOutputStream.WriteLine(string.Format(lang.FILE_EXPLORER_TEXT_40_7, SizeStr, DCreateStr, DModifyStr, DLastAccessStr, AttrStr, pFullName));
                    else FOutputStream.WriteLine(string.Format(lang.FILE_EXPLORER_TEXT_40_7, SizeStr, DCreateStr, DModifyStr, DLastAccessStr, AttrStr, pName));
                }
                catch
                {
                }
            }
            /// <summary>Zaradenie suboru</summary>
            /// <param name="pName">nazov</param>
            /// <param name="pFullName">nazov aj s cestou</param>
            /// <param name="pSize">dlzka</param>
            /// <param name="pDCreate">cas vytvorenia</param>
            /// <param name="pDModify">cas zmeny</param>
            /// <param name="pDLastAccess">cas posledneho pristupu</param>
            /// <param name="pAttributes">atributy</param>
            public void AddFile_XmlMode(string pName, string pFullName, long pSize, DateTime pDCreate, DateTime pDModify, DateTime pDLastAccess, uint pAttributes)
            {
                string SizeStr = ExportSize ? ICore.ToStr(pSize) : "";
                string DCreateStr = ExportDCreate ? ICore.DateTime2Str(pDCreate) : "";
                string DModifyStr = ExportDCreate ? ICore.DateTime2Str(pDModify) : "";
                string DLastAccessStr = ExportDCreate ? ICore.DateTime2Str(pDLastAccess) : "";
                string AttrStr = ExportAttributes ? INode.FormatAttributesAsString(pAttributes, (char)0) : "";

                try
                {
                    FOutputStream.WriteLine("<file>");
                    if (ExportFullName)
                    {
                        FOutputStream.WriteLine("<name />");
                        FOutputStream.WriteLine(string.Format("<fullname>{0}</fullname>", pFullName));
                    }
                    else
                    {
                        FOutputStream.WriteLine(string.Format("<name>{0}</name>", pName));
                        FOutputStream.WriteLine("<fullname />");
                    }
                    if (SizeStr != "") FOutputStream.WriteLine(string.Format("<size>{0}</size>", SizeStr));
                    if (DCreateStr != "") FOutputStream.WriteLine(string.Format("<creation_date>{0}</creation_date>", DCreateStr));
                    if (DModifyStr != "") FOutputStream.WriteLine(string.Format("<last_modify_date>{0}</last_modify_date>", DModifyStr));
                    if (DLastAccessStr != "") FOutputStream.WriteLine(string.Format("<last_access_date>{0}</last_access_date>", DLastAccessStr));
                    if (AttrStr != "") FOutputStream.WriteLine(string.Format("<attributes>{0}</attributes>", AttrStr));
                    FOutputStream.WriteLine("</file>");
                }
                catch
                {
                }
            }
        }

        public IExportListToFileStr Value; // Objekt pre editaciu

        protected IGroupBox FGrp; // Controls
        protected IButton FBtn_OK;
        protected IButton FBtn_Cancel;

        protected IGroupBox FGrp1;
        protected ILabel FLabel1;
        protected IComboBox FCombo_ExportType;
        protected ILabel FLabel2;
        protected IComboBox FCombo_ExportDepth;
        protected ILabel FLabel3;
        protected ICheckBox FCheck_ExportDirNames;

        protected IGroupBox FGrp2;
        protected IComboBox FCombo_ExportFullName;
        protected ICheckBox FCheck_ExportSize;
        protected ICheckBox FCheck_ExportDCreate;
        protected ICheckBox FCheck_ExportDModify;
        protected ICheckBox FCheck_ExportDLastAccess;
        protected ICheckBox FCheck_ExportAttributes;

        /// <summary>Konstruktor</summary>
        public IFileExplorerForm_ExportListToFile()
        {
            Value = new IExportListToFileStr(); // Inicializacia
        }

        /// <summary>Metoda: OnCreateForm</summary>
        /// <returns>true / false</returns>
        protected override bool OnCreateForm()
        {
            if (!base.OnCreateForm()) return false; // Volam predchodcu

            // Inicializacia
            MinimizeBox = false; MaximizeBox = false; FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; ShowIcon = true; ShowInTaskbar = false; StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

            SetBounds(0, 0, 300, 460); System.Drawing.Size CS = ClientSize;
            Text = lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_1;

            // Vytvorim groupbox
            FGrp = new IGroupBox(); IControl.PlaceControl_Inside(FGrp, this, 10, 10, 10, 50);
            System.Drawing.Size CS1 = FGrp.ClientSize;

            FGrp1 = new IGroupBox();
            FLabel1 = new ILabel(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_4);
            FCombo_ExportType = new IComboBox(); FCombo_ExportType.AddMultiItems(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_4_1, '\b', new int[] { IExportListToFileStr.OUTPUT_MODE_TXT, IExportListToFileStr.OUTPUT_MODE_HTML, IExportListToFileStr.OUTPUT_MODE_XML });
            FLabel2 = new ILabel(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_4_2);
            FCombo_ExportDepth = new IComboBox(); FCombo_ExportDepth.AddMultiItems(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_4_3, '\b', new int[] { -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            FCheck_ExportDirNames = new ICheckBox(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_4_4);
            FGrp1.Controls.AddRange(new System.Windows.Forms.Control[] { FLabel1, FCombo_ExportType, FLabel2, FCombo_ExportDepth, FCheck_ExportDirNames });

            FGrp2 = new IGroupBox();
            FCombo_ExportFullName = new IComboBox(); FCombo_ExportFullName.AddMultiItems(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_4_5, '\b', new int[] { 1, 0 });
            FCheck_ExportSize = new ICheckBox(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_4_6);
            FCheck_ExportDCreate = new ICheckBox(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_4_7);
            FCheck_ExportDModify = new ICheckBox(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_4_8);
            FCheck_ExportDLastAccess = new ICheckBox(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_4_9);
            FCheck_ExportAttributes = new ICheckBox(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_4_10);
            FGrp2.Controls.AddRange(new System.Windows.Forms.Control[] { FCombo_ExportFullName, FCheck_ExportSize, FCheck_ExportDCreate, FCheck_ExportDModify, FCheck_ExportDLastAccess, FCheck_ExportAttributes });

            FGrp.Controls.AddRange(new System.Windows.Forms.Control[] { FGrp1, FGrp2 });

            IControl.PlaceControl_Inside_LeftTop_LeftTop(FGrp1, FGrp, 10, 10, FGrp.ClientSize.Width - 20, 160);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FGrp2, FGrp1, 0, 6, FGrp.ClientSize.Width - 20, 180);

            IControl.PlaceControl_Inside_LeftTop_LeftTop(FLabel1, FGrp1, 10, 20);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_ExportType, FLabel1, 4, 8, FGrp1.ClientSize.Width - 28);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel2, FCombo_ExportType, -4, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_ExportDepth, FLabel2, 4, 8, FGrp1.ClientSize.Width - 28);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheck_ExportDirNames, FCombo_ExportDepth, -4, 10);

            IControl.PlaceControl_Inside_LeftTop_LeftTop(FCombo_ExportFullName, FGrp2, 10, 20, FGrp2.ClientSize.Width - 20);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheck_ExportSize, FCombo_ExportFullName, 0, 8);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheck_ExportDCreate, FCheck_ExportSize, 0, 8);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheck_ExportDModify, FCheck_ExportDCreate, 0, 8);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheck_ExportDLastAccess, FCheck_ExportDModify, 0, 8);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheck_ExportAttributes, FCheck_ExportDLastAccess, 0, 8);

            // Vytvorim tlacidla
            FBtn_Cancel = new IButton(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_3); IControl.PlaceControl_Outside_TopRight_RightBottom(FBtn_Cancel, FGrp, 0, 10); FBtn_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            FBtn_OK = new IButton(lang.FORM_EXPORT_ITEMS_TO_LIST_TEXT_2, Event_BtnOKClick); IControl.PlaceControl_Outside_TopRight_LeftTop(FBtn_OK, FBtn_Cancel, 0, 10);

            Controls.AddRange(new System.Windows.Forms.Control[] { FGrp, FBtn_OK, FBtn_Cancel }); // Zaradim do controls

            FillForm(Value);
            AcceptButton = FBtn_OK; CancelButton = FBtn_Cancel; FBtn_OK.Focus();
            return true; // Vsetko OK
        }

        /// <summary>Vyplnenie formulara</summary>
        /// <param name="pValue">objekt pre vyplnenie</param>
        protected void FillForm(IExportListToFileStr pValue)
        {
            FCombo_ExportType.SelectedIntID = pValue.OutputMode;
            FCombo_ExportDepth.SelectedIntID = pValue.ExportDepth;
            FCheck_ExportDirNames.Checked = pValue.ExportDirNames;
            FCombo_ExportFullName.SelectedIntID = pValue.ExportFullName ? 1 : 0;
            FCheck_ExportSize.Checked = pValue.ExportSize;
            FCheck_ExportDCreate.Checked = pValue.ExportDCreate;
            FCheck_ExportDModify.Checked = pValue.ExportDModify;
            FCheck_ExportDLastAccess.Checked = pValue.ExportDLastAccess;
            FCheck_ExportAttributes.Checked = pValue.ExportAttributes;
        }
        /// <summary>Nacitanie obsahu formulara</summary>
        /// <param name="Result">vysledok</param>
        protected void ReadForm(IExportListToFileStr Result)
        {
            Result.OutputMode = FCombo_ExportType.SelectedIntID;
            Result.ExportDepth = FCombo_ExportDepth.SelectedIntID;
            Result.ExportDirNames = FCheck_ExportDirNames.Checked;
            Result.ExportFullName = FCombo_ExportFullName.SelectedIntID == 1;
            Result.ExportSize = FCheck_ExportSize.Checked;
            Result.ExportDCreate = FCheck_ExportDCreate.Checked;
            Result.ExportDModify = FCheck_ExportDModify.Checked;
            Result.ExportDLastAccess = FCheck_ExportDLastAccess.Checked;
            Result.ExportAttributes = FCheck_ExportAttributes.Checked;
        }

        /// <summary>Event: Click pre tlacidlo OK</summary>
        /// <param name="pSender">zdroj</param>
        /// <param name="e">parameter</param>
        protected void Event_BtnOKClick(object pSender, EventArgs e)
        {
            ReadForm(Value); // Nacitam data
            DialogResult = System.Windows.Forms.DialogResult.OK; // OK
        }
    }
}
